class TreeNode:
    def __init__(self, value):
        self.value = value
        self.left = None
        self.right = None

class BinarySearchTree:
    def __init__(self):
        self.root = None

    def insert(self, value):
        # 练习点-1: 实现二叉搜索树的插入操作
        if self.root is None:
            self.root = TreeNode(value)
        else:
            self._insert_recursive(self.root, value)

    def _insert_recursive(self, node, value):
        if value < node.value:
            if node.left is None:
                node.left = TreeNode(value)
            else:
                self._insert_recursive(node.left, value)
        else:
            if node.right is None:
                node.right = TreeNode(value)
            else:
                self._insert_recursive(node.right, value)

    def search(self, value):
        # 练习点-2: 实现二叉搜索树的查找操作
        return self._search_recursive(self.root, value)

    def _search_recursive(self, node, value):
        if node is None:
            return False
        if value == node.value:
            return True
        elif value < node.value:
            return self._search_recursive(node.left, value)
        else:
            return self._search_recursive(node.right, value)

    def inorder_traversal(self):
        # 练习点-3: 实现二叉树的中序遍历
        result = []
        self._inorder_recursive(self.root, result)
        return result

    def _inorder_recursive(self, node, result):
        if node:
            self._inorder_recursive(node.left, result)
            result.append(node.value)
            self._inorder_recursive(node.right, result)

# 主程序
if __name__ == '__main__':
    bst = BinarySearchTree()
    
    # 从输入读取数据
    values = list(map(int, input().split()))
    
    # 插入节点
    for value in values:
        bst.insert(value)
    
    # 中序遍历并输出
    inorder_result = bst.inorder_traversal()
    print(" ".join(map(str, inorder_result)))